<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>任教课程-云校通-教师</title>
<jsp:include page="/WEB-INF/page/common/_header.jsp"></jsp:include>
<body ontouchstart style="background:#fff;">
	<div class="weui_tab tab-bottom">
		<div class="weui-header bg-blue"> 
	  		<div class="weui-header-left"> <a onclick="back()" href="javascript:" class="icon icon-109 f-white">返回</a> </div>
	    	<h1 class="weui-header-title">任教课程</h1>
	    </div>
		<div class="weui_tab_bd">
		    <div class="weui_cells afterNone mt0 pb55">
		    	<div class="weui_cell" id="signLine" style="padding: 10px 0px;">
		            <div class="page-bd" style="width: 100%;">
		              <ul>
		              	<c:forEach var="item" items="${list }">
			              	<li class="border-bottom1">
			                    <div class="weui-header weui-flex js-category" data-id="${item.id }">
			                        <img src="<%=basePath %>/images/wderjbj@3x.png">
			                        <p class="weui-flex-item">${item.courseName }</p>
			                        <i class="icon icon-74"></i>
			                    </div>
			                    <div class="page-category js-categoryInner">
					                
					            </div>
			                </li>
		              	</c:forEach>
		              </ul>
		            </div>
		          </div>
		    </div>
		</div>
	</div>
	
	<!--弹窗-->				
	<div class="weui_mask ueureiu weui_mask_visible" style="display: none;">
	</div>
	<div class="weui_dialog ueureiu weui_dialog_visible" style="display: none;">
	
		<div class="weui_dialog_bd" style="padding: 0;">
			
			<div class="weui_panel weui_panel_access">
	            <div class="weui_panel_bd" id="telList">
	            </div>
	        </div>
		</div>
	
	</div>
	<!--End弹窗-->
</body>
<jsp:include page="/WEB-INF/page/common/_footer.jsp"></jsp:include>
<script type="text/javascript">
	$(function() {
		$('.js-category').click(function(){
			$parent = $(this).parent('li');
            if($parent.hasClass('js-show')){
                $parent.removeClass('js-show');
                $(this).children('i').removeClass('icon-35').addClass('icon-74');
            }else{
                $parent.siblings().removeClass('js-show');
                $parent.addClass('js-show');
                $(this).children('i').removeClass('icon-74').addClass('icon-35');
                $parent.siblings().find('i').removeClass('icon-35').addClass('icon-74');
                getStuList($(this));
            }
	     });
		//隐藏弹出框
		$(".weui_mask").click(function(){
			$(".weui_mask").hide();
			$(".weui_dialog").hide();
			$("#telList").html('');
		});
	})
	function getStuList(thiz) {
    	if(thiz.next().html().trim() != '') return;
    	$.ajax({
   	 		url : basePath + "/ls/interest/course/teachingCourse/stuList",
   	 		type : "post",
   	 		dataType : "json",
   	 		data: {
   	 			courseId: thiz.attr("data-id")
   	 		},
   	 		async : false,
   	 		success : function(data) {
   	 			if(data != null && data.length > 0) {
   	 				var html = '<div class="weui_cells weui_cells_access bg_gry mt0">\
   	 								<div class="weui_cell lblue afterNone afterNoneBefore bg_gry b_left">\
   	 									<div class="weui_cell_bd weui_cell_primary"><p>学生列表</p></div>\
   	 								</div>\
   	 							</div>';
   	 				
   	 				for(var i in data) {
   	 					var itm = data[i];
   	 					html+= '<div class="weui_cell bg-white clear">\
			   	 					<div class="weui_cell_bd weui_cell_primary f-15">\
				   	 					<p class="xcgl_student_wrap"><span style="width: 50%;">'+itm.gradeName+'（'+itm.clazz+'）班</span><span>'+itm.studentName+'</span></p>\
				   	 				</div>\
				   	 				<div class="weui_cell_ft bgNone" onclick="telList('+itm.grade+','+itm.clazz+')">\
				   	 					<img class="xcgl-tel" style="width:20px;" src="<%=basePath%>/images/dianhua@3x.png">\
				   	 				</div>\
				   	 			</div>';
   	 				}
   	 				html += '</div>';
   	 				thiz.next().html(html);
   	 			}
   	 		}, error:function(){
  	 			$.toptips("查询异常");
     		}
	 	});
	}
	//电话
	function telList(grade, clazz){
		$(".weui_mask").addClass("weui_mask_visible").removeAttr("style").show();
		$.ajax({
    		url: basePath + "/ls/schoolbus/teacherPhone",
    		type: 'POST',
    		dataType : "json",
    		data: {
    			grade: grade,
    			clazz: clazz
    		},
    		success: function(data) {
    			if(data != null && data.length > 0) {
    				$(".weui_dialog").addClass("weui_dialog_visible").removeAttr("style").show();
    				var telListHtml = "";
    				for(var i in data) {
    					telListHtml += '<a href="tel:'+data[i].phone+'" class="weui_media_box weui_media_appmsg">\
		                    <div class="weui_media_bd tleft">\
		                        <h4 class="weui_media_title pl20"><span style="display: inline-block;min-width: 100px;">'+data[i].roleName+'</span> <span class="f-blue">'+data[i].phone+'</span></h4>\
		                    </div>\
		                </a>';
    				}
		            $("#telList").html(telListHtml);
    			}
    		},
    		error: function(data) {
    			alert("系统异常,请联系管理员");
    		}
    	});
	}
</script>
</html>